﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace BDSim
{
    //Add by ZLY
    #region 观测数据生成误差控制及模型选择

    #region 观测误差控制开关
    /// <summary>
    /// 观测数据生成误差控制开关
    /// </summary>
    public struct ObsErrFlag
    {
        /// <summary>
        /// 卫星钟差开关，true：考虑；false：不考虑
        /// </summary>
        public bool IsSatClk;

        /// <summary>
        /// 接收机钟差开关
        /// </summary>
        public bool IsStaClk;

        /// <summary>
        /// 电离层开关
        /// </summary>
        public bool IsIion;

        /// <summary>
        /// 对流层开关
        /// </summary>
        public bool IsItro;

        /// <summary>
        /// 多路径开关
        /// </summary>
        public bool IsImul;

        /// <summary>
        /// 相对论效应开关
        /// </summary>
        public bool IsIrel;

        /// <summary>
        /// 相位中心偏移误差开关
        /// </summary>
        public bool IsIoff;

        /// <summary>
        /// 随即误差开关
        /// </summary>
        public bool IsIran;
    }

    #endregion

    #region 观测误差模型配置

    #region 钟差模型配置
    /// <summary>
    /// 卫星钟差模型
    /// </summary>
    public enum ESatClkModelType
    {
        多项式模型,
    }

    /// <summary>
    /// 用户钟差模型
    /// </summary>
    public enum EStaClkModelType
    {
        多项式模型,
    }
    #endregion

    #region 电离层配置
    /// <summary>
    /// 电离层延迟映射模型
    /// </summary>
    public enum EIonMappingModelType
    {
        电离层映射函数,
    }

    /// <summary>
    /// 电离层延迟改正模型
    /// </summary>
    public enum EIonModelType
    {
        EightParam,
        FourteenParam,
        Grid,
        DoubleFre,
    }
    #endregion 电离层配置

    #region 对流层配置

    #region 气象参数
    /// <summary>
    /// 获取气象参数方式
    /// </summary>
    public enum EWayToGetMeteorological
    {
        /// <summary>
        /// 利用SHAO模型计算
        /// </summary>
        SHAOModel,

        /// <summary>
        /// 用户输入气象参数
        /// </summary>
        用户输入,
    }

    /// <summary>
    /// 气象参数值
    /// </summary>
    public struct  MeteorologicalsParam
    {
        /// <summary>
        /// 气温
        /// </summary>
        public double Temperature;

        /// <summary>
        /// 气压
        /// </summary>
        public double Pressure;
        
        /// <summary>
        /// 相对湿度
        /// </summary>
        public double RelativeHumidity;
    }


    #endregion

    /// <summary>
    /// 对流层延迟计算模型
    /// </summary>
    public enum ETroModelType
    {
        Hopfield,
        ImprovedHopfield,
        Saastamoinen,
    }


    /// <summary>
    /// 对流层配置
    /// </summary>
    public struct TroSet
    {
        /// <summary>
        /// 气象参数配置
        /// </summary>
        public EWayToGetMeteorological WayToGetMeteorological;

        /// <summary>
        /// 对流层模型选择
        /// </summary>
        public ETroModelType TroModel;
    }

    #endregion 对流层配置

    #region 多路径配置
    /// <summary>
    /// 多路径模型
    /// </summary>
    public enum EMulModelType
    {
        常量模型,
    }

    #endregion 多路径配置

    #region 相对论效应模型配置
    /// <summary>
    /// 相对论效应计算模型
    /// </summary>
    public enum ERelModelType
    {
        自定义模型,
    }

    #endregion 相对论效应模型配置

    #region 相位中心偏移模型配置
    /// <summary>
    /// 相位中心偏移误差计算模型
    /// </summary>
    public enum EOffModelType
    {
        自定义模型,
    }
    #endregion 相位中心偏移模型配置

    #region 随机噪声设置
    /// <summary>
    /// 随机噪声类型
    /// </summary>
    public enum ERanType
    {
        白噪声模型,
    }

    /// <summary>
    /// 噪声量级
    /// </summary>
    public struct RanOrder
    {
        /// <summary>
        /// 生成伪距时考虑的随机噪声量级
        /// </summary>
        public double PseudoRanOrder;

        /// <summary>
        /// 生成载波相位时考虑的随机噪声量级
        /// </summary>
        public double CarrywaveRanOrder;
    }


    /// <summary>
    /// 随机噪声设置
    /// </summary>
    public struct RanSet
    {
        /// <summary>
        /// 随机噪声类型
        /// </summary>
        public ERanType Ran_Type;

        /// <summary>
        /// 随机噪声量级
        /// </summary>
        public RanOrder Ran_Order;
    }

    #endregion 随机噪声设置

    #endregion 观测误差模型配置

    #endregion 观测数据生成误差控制及模型选择

    #region 星地下行输出的观测数据
    /// <summary>
    /// 监测站单接收机对单颗卫星的单频点观测数据
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct SingleSatObs
    {
        /// <summary>
        /// 频点信息，指明是哪个频点产生的观测数据
        /// </summary>
        public EFrePoint FrePoint;
        /// <summary>
        /// 伪距
        /// </summary>
        public double A_Pseudo_writein;

        /// <summary>
        /// 载波相位测量值-3个频点
        /// </summary>
        public double A_Carri_writein;

        /// <summary>
        /// 多普勒频移
        /// </summary>
        public double DoplShift;

        /// <summary>
        /// 伪距一阶变率
        /// </summary>
        public double DotPseudo;
    };

    /// <summary>
    /// 接收机对单颗卫星的观测值输出
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct ObsReceiverOutput
    {
        /// <summary>
        /// 接收机ID号
        /// </summary>
        public int ReceiverID;

        /// <summary>
        /// 观测数据的生成时刻
        /// </summary>
        public UTCTime ObsTime;

        /// <summary>
        /// 指示卫星与地面站之间的可见性，0：不可见；1：可见
        /// </summary>
        public int ObsFlag;

        /// <summary>
        /// 卫星编号
        /// </summary>
        public int SatID;

        /// <summary>
        /// 对该可见卫星的观测数据（最多三个频点）
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
        public SingleSatObs[] SatObs;

        /// <summary>
        /// 卫星钟差引起的伪距延迟
        /// </summary>
        public double DeltSatClkErr;

        /// <summary>
        /// 电离层延迟
        /// </summary>
        public double DeltIon;

        /// <summary>
        /// 对流层延迟
        /// </summary>
        public double DeltTro;

        /// <summary>
        /// 多路径延迟
        /// </summary>
        public double DeltMul;

        /// <summary>
        /// 相对论效应引起的伪距延迟
        /// </summary>
        public double DeltRel;

        /// <summary>
        /// 相位中心偏移引起的伪距延迟
        /// </summary>
        public double DeltOff;

        /// <summary>
        /// 系统随机误差
        /// </summary>
        public double DeltRan;

        /// <summary>
        /// 地面站钟差引起的伪距延迟
        /// </summary>
        public double StaClkErr;

        /// <summary>
        /// 观测值生成时刻卫星轨道信息
        /// </summary>
        public NodePosVel SatPV;

        /// <summary>
        /// 当前整周模糊度
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
        public double[] InitAmbiguity;
    };

    #endregion 星地下行输出的观测数据
}
